A flexible Prolog interpreter in Python

نویسنده

  • Carl Friedrich Bolz
چکیده

Efficient virtual machines for the Prolog programming language (and also for other dynamic highlevel languages) are usually large and intricate pieces of software implemented in a low-level language such as C that are extensively optimized over many years and are therefore difficult to change in many respects. Due to their inherent complexity it is hard to develop them further, to maintain them or to use them to experiment with language extensions or new built-ins. Early implementation decisions, such as choice of garbage collector, are extremely hard to change afterwards. In addition, it is also much harder to perform advanced optimizations or transformations (such as partial evaluation) on the virtual machine itself due to the low level of the implementation language. Furthermore it is (by definition) impossible to port them to a non-C platform such as the Java Virtual Machine or the .NET framework Therefore the numerous implementations of a Prolog virtual machine integrated into one of these environments are all new implementations which have to be maintained themselves and therefore all have different levels of maturity and slightly different sets of built-ins available. Using a higher-level language than C addresses many of these problems. It allows the language implementor to work at a higher level of abstraction, which eases implementation, maintenance and extensions of the virtual machine and reduces the size of the code base. Furthermore, advanced optimizations and transformations can be performed. To regain usable performance the implementation needs then to be translated to a low-level language again. The goal of the PyPy project is to support the implementation of interpreters in the high-level language Python. Python is an object oriented dynamic language which is becoming more and more popular for scripting use as well as for “real” applications. PyPy provides a translation toolchain that helps to translate interpreters written in Python to a low-level language such as C and the .NET Intermediate Language. To make this translation work, these interpreters have to be written in RPython, which is a proper subset of Python chosen in such a way that it is amenable to analysis. In this talk we give an quick overview of the PyPy project and present a Prolog interpreter written in RPython, exploring the possibilities of implementing a well-known declarative language in a high-level language (as opposed to C). One of the main goals of the implementation was to keep it as simple and as extensible as possible (even at the cost of performance). The PyPy tool suite is used to reach a reasonable level of performance and to ensure portability to various platforms.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Prolog Interpreter in Python

We provide a proof-of-concept for a new approach to flexible and portable implementation of programming languages. More precisely, we describe the implementation of a Prolog interpreter in RPython, a restricted subset of the Python language intended for system programming. RPython can be translated using the PyPy compilation and specialization tool-set to various platforms, among them C/Posix a...

متن کامل

Approaches to Interpreter Composition

In this paper, we compose six different Python and Prolog VMs into 4 pairwise compositions: one using C interpreters; one running on the JVM; one using meta-tracing interpreters; and one using a C interpreter and a meta-tracing interpreter. We show that programs that cross the language barrier frequently execute faster in a meta-tracing composition, and that meta-tracing imposes a significantly...

متن کامل

Jitting Prolog for Fun and Profit

Most Prolog implementations are implemented in low-level languages such as C and are based on a variation of the WAM instruction set, which enhances their performance but makes them hard to write. In addition, many of the more dynamic features of Prolog (like assert), despite their popularity, are not well supported. We present a high-level continuation-based Prolog interpreter based on the PyP...

متن کامل

Meta-tracing makes a fast Racket

Tracing just-in-time (JIT) compilers record and optimize the instruction sequences they observe at runtime. With some modifications, a tracing JIT can perform well even when the executed program is itself an interpreter, an approach called meta-tracing. The advantage of meta-tracing is that it separates the concern of JIT compilation from language implementation, enabling the same JIT compiler ...

متن کامل

Prolog, Refinements and RLGG's

Cohen’s [1] refinement rules provide a flexible mechanism for introducing intentional background knowledge in an ILP system. Whereas Cohen used a limited second order theorem prover to implement the rule interpreter, we extend the method to use a full Prolog interpreter. This makes the introduction of more complex background knowledge possible. Although refinement rules have been used to genera...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2006